package com.java.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

public class TCPClientC {
	public static void main(String[] args) {
		Socket s=null;
		PrintWriter pw=null;
		BufferedReader br=null;
		try {
			s=new Socket("127.0.0.1",8888);
			pw=new PrintWriter(s.getOutputStream());
			pw.println("hellotonyheihei");
			pw.flush();
			br=new BufferedReader(new InputStreamReader(s.getInputStream()));
			String str;
			while((str=br.readLine())!=null){
				System.out.println(str);
			}
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
